package com.xuzao.developer.dao.impl;

import com.xuzao.developer.tools.base.BaseServiceSupport;
import com.xuzao.developer.base.model.SysResource;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xuzao.developer.base.criteria.SysResourceCriteria;
import com.xuzao.developer.tools.entity.Pager;
import com.xuzao.developer.mapper.SysResourceMapper;
import com.xuzao.developer.dao.SysResourceDao;

import javax.annotation.Resource;

import com.xuzao.developer.dto.SysResourceDTO;
import org.springframework.stereotype.Service;


/**
 * @description 
 * @author xuzao
 * @date 2019-09-19 09:38:12
 **/
@Service("sysResourceDao")
public class SysResourceDaoImpl extends BaseServiceSupport<SysResource> implements SysResourceDao {

	@Resource
	private SysResourceMapper sysResourceMapper;


	@Override
	public PageInfo<SysResource> list(SysResourceDTO dto, Pager pager) {
		SysResourceCriteria criteria = this.assemblyQuerycond(dto);
		if (null != pager) {
			if (null != pager.getPageSize() && null != pager.getPageIndex()) {
				PageHelper.startPage(pager.getPageIndex(), pager.getPageSize());
			}
		}
		PageInfo<SysResource> pageInfo = new PageInfo<>(this.sysResourceMapper.selectByExample(criteria));
		return pageInfo;
	}

	//通用查询方法条件组装
	public SysResourceCriteria assemblyQuerycond(SysResourceDTO dto) {
		SysResourceCriteria criteria = new SysResourceCriteria();
		SysResourceCriteria.Criteria c = criteria.createCriteria();

		if (null != dto) {

		}
		return criteria;
	}

	@Override
	public void deleteAll() {
		sysResourceMapper.deleteAll();
	}
}